<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
</head>
<body>
	 <div class="container">
	 <a class="btn btn-success" href="${pageContext.request.contextPath}/addstudent.jsp">添加学生</a>
	 <a class="btn btn-success" onclick="logOut()">注销</a>
	 <a href="${pageContext.request.contextPath}/onLine.jsp">在线列表</a>
	 	<table class="table table-striped table-bordered table-hover table-condensed">
	 		<tr>
	 			<td>编号</td>
	 			<td>姓名</td>
	 			<td>年龄</td>
	 			<td>性别</td>
	 			<td>班级编号</td>
	 			<td>修改</td>
	 			<td>删除</td>
	 		</tr>
	 		<c:forEach items="${pageBean.list}" var="student">
				<tr>
					<td>${student.id}</td>
					<td>${student.name}</td>
					<td>${student.age}</td>
					<td>${student.gender}</td>
					<td>${student.banji_id}</td>
					<td><a href="${pageContext.request.contextPath}/student?method=toUpdate&id=${student.id}">修改</a></td>
					<%-- <td><a href="javascript:void(0)" onclick="deleteById(${student.id})">删除</a></td> --%>
					<td><a onclick="deleteById(${student.id})">删除</a></td>
				</tr>	 		
	 		</c:forEach>
	 	</table>
	 	<nav aria-label="Page navigation">
		  <ul class="pagination">
		  <c:if test="${pageBean.pageNo == 1}">
		  	<li class="disabled">
		      <a href="#" aria-label="Previous">
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		  </c:if>
		  <c:if test="${pageBean.pageNo != 1}">
		  	<li>
		      <a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${pageBean.pageNo-1}&pageSize=3" aria-label="Previous">
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		  </c:if>
		    <c:forEach begin="1" end="${pageBean.totalPage}" var="i">
		    	<c:if test="${i == pageBean.pageNo}">
		    		<li class="active"><a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${i}&pageSize=3">${i}</a></li>
		    	</c:if>		
		    	<c:if test="${i != pageBean.pageNo}">
		    		<li><a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${i}&pageSize=3">${i}</a></li>
		    	</c:if>		
		    </c:forEach>
		    <c:if test="${pageBean.pageNo == pageBean.totalPage}">
			    <li class="disabled">
			      <a href="#" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
		    </c:if>
		    <c:if test="${pageBean.pageNo != pageBean.totalPage}">
			    <li>
			      <a href="${pageContext.request.contextPath}/student?method=pageList&pageNo=${pageBean.pageNo+1}&pageSize=3" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
		    </c:if>
		  </ul>
		</nav>
	 </div>
	 <script src="${pageContext.request.contextPath}/lib/jquery/jquery-1.11.1.js" type="text/javascript" charset="utf-8"></script>
	 <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layer/layer.js" ></script>
	 <script type="text/javascript">
	 	function deleteById(id){
	 		layer.confirm(
	 			"确认要删除吗？",
	 			function(index){
	 				location.href="${pageContext.request.contextPath}/student?method=delete&id="+id;
	 				layer.close(index);
	 			}
	 		)
	 	}
	 	function logOut(){
	 		var isLogOut = confirm("确认要注销吗？");
	 		if(isLogOut){
	 			location.href="${pageContext.request.contextPath}/user?method=logOut";
	 		}
	 	}
	 </script>
</body>
</html>